package qeug.shsh.fi.fromPlugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.plugin.AbstractFormPlugin;

public class WBSFromPlugin extends AbstractFormPlugin {
    @Override
    public void propertyChanged(PropertyChangedArgs e) {
        super.propertyChanged(e);
        String fieldKey = e.getProperty().getName();
        if ("expenseitem".equals(fieldKey)) {
            ChangeData[] changeSet = e.getChangeSet();
            ChangeData changeData = changeSet[0];
            DynamicObject expenseItem = (DynamicObject) changeData.getNewValue();//费用名目
            if (expenseItem!=null){
                String expenseItemNum = expenseItem.getString("number");
                if (expenseItemNum.contains("FYXM0048") || expenseItemNum.contains("FYXM0009")) {
                    this.getView().setEnable(false, "qeug_wbs");
                } else {
                    this.getView().setEnable(true, "qeug_wbs");
                }
            }else {
                this.getView().setEnable(true, "qeug_wbs");
            }
        } else if ("noinvoice".equals(fieldKey)) {
            boolean noinvoice = (boolean) this.getModel().getValue("noinvoice");
            if (noinvoice) {
                this.getView().setEnable(false, "qeug_wbs");
            } else {
                this.getView().setEnable(true, "qeug_wbs");
            }
        }
    }
}
